<?php
// no direct access
defined('_JEXEC') or die('Restricted access');

/**
 * This is a file to add template specific chrome to pagination rendering.
 *
 * pagination_list_render
 *	Input variable $list is an array with offsets:
 *		$list[all]
 *			[data]		: string
 *			[active]	: boolean
 *		$list[start]
 *			[data]		: string
 *			[active]	: boolean
 *		$list[previous]
 *			[data]		: string
 *			[active]	: boolean
 *		$list[next]
 *			[data]		: string
 *			[active]	: boolean
 *		$list[end]
 *			[data]		: string
 *			[active]	: boolean
 *		$list[pages]
 *			[{PAGE}][data]		: string
 *			[{PAGE}][active]	: boolean
 *
 * pagination_item_active
 *	Input variable $item is an object with fields:
 *		$item->base	: integer
 *		$item->prefix	: string
 *		$item->link	: string
 *		$item->text	: string
 *
 * pagination_item_inactive
 *	Input variable $item is an object with fields:
 *		$item->base	: integer
 *		$item->prefix	: string
 *		$item->link	: string
 *		$item->text	: string
 *
 * This gives template designers ultimate control over how pagination is rendered.
 *
 * NOTE: If you override pagination_item_active OR pagination_item_inactive you MUST override them both
 */

function pagination_list_render($list) {
	$html = '<ol>';
	if ($list['previous']['active']) {
		$html .= $list['previous']['data'];
	}
	foreach($list['pages'] as $page) {
		$html .= $page['data'];
	}
	if ($list['next']['active']) {
		$html .= $list['next']['data'];
	}
	$html .= '</ol>';
	return $html;
}

function pagination_item_active(&$item) {
	$html  = '<li>';
	$html .= '<a href="' . $item->link . '">';
	if ($item->text === JText::_('JNEXT')) {
		$html .= '<img class="v-middle" alt="Next" src="' . JURI::base() . '/templates/mphq/images/pager_arrow_right.gif" />';
	} else if ($item->text === JText::_('JPREV')) {
		$html .= '<img class="v-middle" alt="Previous" src="' . JURI::base() . '/templates/mphq/images/pager_arrow_left.gif" />';
	} else {
		$html .= $item->text;
	}
	$html .= '</a>';
	$html .= '</li>';
	
	return $html;
}

function pagination_item_inactive(&$item) {
	return '<li class="current">' . $item->text . '</li>';
}
?>
